public class demo1 {
    class Solution {
        public int maxArea(int[] height) {
            int n=height.length;
            int ret=0;
            for(int i=0;i<n;i++){
                for(int j=i+1;j<n;j++){
                    int x=j-i;
                    int sum=0;
                    if(x==0||x==1){
                        sum=Math.min(height[i],height[j]);
                    }else{
                        sum=Math.min(height[i],height[j])*x;
                    }
                    ret=Math.max(ret,sum);
                }
            }
            return ret;
        }
    }
    class Solution1 {
        public int maxArea(int[] height) {
            int n=height.length;
            int left=0;
            int right=n-1;
            int ret=0;
            while(left<right){
                ret=Math.max(ret,Math.min(height[left],height[right])*(right-left));
                if(height[left]<height[right])left++;
                else{
                    right--;
                }
            }
            return ret;
        }
    }
}
